<?php
/**
 * @fileoverview    我的首页的  宝贝分享接口
 * @author          zhanglei 11
 * @date            Feb  02 11:31:49 CST 2012
 * @copyright       sina meila
 */

include_once '../../__global.php';
include_once './scroll_public.php';
class aj_getPicFeed extends scroll_public{

    public function main(){
        
        //获得我关注的人的uid
        $oFollow = new ml_model_dbFollow();        
        $oFollow->getList($this->__visitor['uid'],0,200);
        $rs = $oFollow->get_data();
        
        
        $uids = array();
        if(is_array($rs) && count($rs) > 0){
            foreach($rs as $k => $v) {
                $uids[] = $v['follow_uid'];
            }
        }else{
            global $defaultUids;
            $uids = $defaultUids;
        }
        
        
        
        $begin = ($this->_pagenum - 1) * ML_FEED_PAGESIZE * 3 + ($this->_offset-1) * ML_FEED_PAGESIZE;
        //    获取feed
        $oPic = new ml_model_dbPicFeed();        
        $rs = $oPic->getCntByUids($this->__visitor['uid'],$uids);
        $cnt = $oPic->get_data();
        $this->total = isset($cnt[0]) ? $cnt[0] : 0;
        
        
        
        $oPic->getListByUids($this->__visitor['uid'],$begin,ML_FEED_PAGESIZE,$uids);
        $feed = $oPic->get_data();
        
        //    数据结构不统一
        if(is_array($feed))
        foreach ($feed as $k => $v) {
            
            if(!empty($v['content_rid'])) {
              $feed[$k]['rid'] = $v['content_rid'];
              $rids[] = $v['content_rid'];
            }else{                
                $feed[$k]['rid'] = $v['feed_info']['rid'];
                $rids[] = $v['feed_info']['rid'];
            }
            $feed[$k]["pin_type"] = 'verify_other';
        }
        
        $oContent = new ml_model_dbContent();
        $contents = $oContent->get_content_by_rids($rids);        
        
         
          $pin=new ml_biz_pin_indexData();            
        $feed = $pin->output($this->__visitor['uid'],$feed,$contents);
        
        $last=count($feed)<ML_FEED_PAGESIZE?true:false;
        $finnal['lastSegment']=$last;
        
        $finnal['items'] = empty($feed)?'':$feed;
        
        $this->api_output(ML_RCODE_SUCC,$finnal);

    }
}
new aj_getPicFeed();
?>